In a functional programming interface, all routines are provided as functions. Parameters are passed to a function to give values to variables that are used within the function. A variable is a named storage location capable of containing a certain type of data that can be modified during execution of the function. Each variable has a data type, which specifies the possible range of values for the variable, the operations that can be performed on the values, and the way in which the values are stored in memory.
To ensure that the correct data types are being used for a variable, a compiler can be used to perform type checking operations. For example, if a function requires two integers as parameters, but a calling program attempts to pass an integer and a floating point value to the function, then a compiler performing type checking would uncover the error. A compiler, however, is limited in the degree of parameter testing that it can perform. Suppose a function has a variable FileName as one of its formal parameters, and the variable FileName is defined as type character. A compiler would not verify that a valid file existed with the name FileName. A compiler would only check to see if the actual parameter is of type character.
During development of a function, it is important for the programmer to test the function to see how the function will behave with different input values as parameters. Oftentimes a function will behave incorrectly when an invalid parameter is passed to the function, thereby disrupting the normal program flow. Function tests are actually based on parameter types. To understand how parameter types interact with a function, consider the following function prototype:
BOOL FOOBAR (HWND hWindow, HICON hIcon);
The parameter types in this particular example are HWND (handle to a window), and HICON (handle to an icon). The function name is FOOBAR. A window handle would be a valid value for HWND, but a handle to a file or a handle to memory would be an invalid value.
Programmers perform parametric testing of functions to test how functions react to valid and invalid parameters. To perform parametric testing of a function in prior art systems, programmers write modules of test code to pass valid and invalid parameters to the function, and then observe the behavior of the function. If a valid parameter is passed to the function, then the function should execute without any problems. If an invalid parameter is passed to the function, then the function should return a proper error message or a return code.
The primary disadvantage of this approach is that the test code written by each programmer is not reused by other programmers testing the same parameters in different functions. Because programmers are each developing their own test code, duplication of code is unavoidable, resulting in considerable expenditure of time and effort. Also, with each programmer writing separate modules of code, it is difficult to be aware of each programmer's methodology of parametric testing.
Parametric testing is a time-consuming task. When testing all of the functions in the application programming interface to Microsoft Windows, for example, programmers must write modules of test code for approximately 1,000 functions, each function having on an average of 3-4 parameters. Additionally, each parameter has numerous valid and invalid values that need to be tested. It would be advantageous to have an automated method of parametric testing.
It would also be advantageous to have a method of parametric testing that would allow programmers to easily utilize work done by other programmers. The method of parametric testing should eliminate redundancies in test coding by allowing programmers to share uniformly-created test modules. By sharing test modules uniformly created by different programmers, an individual programmer could generate much more complete test coverage than using prevalent testing methods. The more complete coverage would result in more thorough testing of the functions in question. More thorough testing would save money by preventing expensive product updates to correct errors, and the high product quality ensured by the thorough testing would enhance a software product's reputation and marketability.